
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
<%@ page import="com.google.appengine.api.images.Image" %>
<%@ page import="com.tpix.PixieCore" %>

<% 
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	String url =  blobstoreService.createUploadUrl("/upload");
 %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
	<!-- Get references to Java objects -->
	<%  PixieCore core = (PixieCore) request.getSession().getAttribute("core");
		if (core == null) {
			core = new PixieCore();
			request.getSession().setAttribute("core", core);
		} %>
		
	<%-- Detect User Logged In --%>
	<%  if (!core.loggedIn()) {
			// user is not logged in. Redirect to login page
			response.sendRedirect("/login.jsp");
		} %>
	
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Pixie - Upload a photo!</title>
		
		<!-- CSS -->
		<link type="text/css" rel="stylesheet" href="/stylesheets/upload.css" />
		<link type="text/css" rel="stylesheet" href="/stylesheets/960.css" />
		
		<!-- TypeKit -->
		<script type="text/javascript" src="http://use.typekit.com/waa6dbj.js"></script>
		<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
		<!--  Validator -->
	    <script type="text/javascript" src="/js/validator.js"></script>	
	</head>
	
	<body>
		
		<div class="container_12">	
		<div id="wrapper">
		
		<div id="logo">
			<img src="/images/pixie_home_upload_logo.png" alt="Hello, Pixie"/>
		</div>
		
		<div class="grid">
			<form name="upload" method="POST" action="<%= url %>" enctype="multipart/form-data" onSubmit="return validateForm()")>
				
				<div class="grid_2 push_1">
					<div class="fileinputs">
						<input type="file" name="file" class="file" />
						<div class="fakefile">
							<img src="/images/select_photo.png" />
						</div>
					</div>
				</div>
				
				<div class="grid_2 push_1">
					<input type="image" value="Upload" src="/images/upload_button.png" />
				</div>
			</form>
			
		</div>
		<div class="clear"></div>
		
		<!-- User name -->
	<div class="grid_4 push_1">
		<div id="user_name">
		
		Signed in as:
			<% out.println( core.getUserName() + 
					" (<a href=\"" + core.getLogoutURL(request) + "\">sign out</a>)"); %>
		</div> 
	</div> <!-- /user name -->
		
		</div>
		</div>
		
	</body>
</html>